Expand description
A basic building block for building an Eventsource from a Stream of bytes array like objects. To learn more about Server Sent Events (SSE) take a look at the MDN docs
§Example
ⓘ
let mut stream = reqwest::Client::new()
.get("http://localhost:7020/notifications")
.send()
.await?
.bytes_stream()
.eventsource();
while let Some(event) = stream.next().await {
match event {
Ok(event) => println!(
"received event[type={}]: {}",
event.event,
event.data
),
Err(e) => eprintln!("error occured: {}", e),
}
}
Structs§
- An Event
- A Stream of events
Enums§
- Error thrown while parsing an event line
Traits§
- Main entrypoint for creating
crate::Event
streams